package intro.databases.gtCarRental.ui.employee;

import java.sql.ResultSet;
import java.sql.SQLException;

import intro.databases.gtCarRental.GTCRActivity;
import intro.databases.gtCarRental.R;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

public class MaintenanceHistoryReport extends GTCRActivity {
	LinearLayout table;

	@Override
	public void onCreate(Bundle b) {
		super.onCreate(b);
		setContentView(R.layout.maintenance_history_report);

		table = (LinearLayout) findViewById(R.id.linearLayout_maintenanceHistoryReport_table);

		ResultSet rS = dbConn.MaintenanceHistoryReport();
		try {
			while(rS.next()) {
				View v = getLayoutInflater().inflate(R.layout.maintenance_history_report_tablerow, null);

				TextView car = (TextView) v.findViewById(R.id.textView_maintenanceHistoryReport_car);
				TextView dateTime = (TextView) v.findViewById(R.id.textView_maintenanceHistoryReport_dateTime);
				TextView employee = (TextView) v.findViewById(R.id.textView_maintenanceHistoryReport_employee);
				TextView problems = (TextView) v.findViewById(R.id.textView_maintenanceHistoryReport_problem);

				car.setText(rS.getString(1));
				dateTime.setText(rS.getString(2));
				employee.setText(rS.getString(3));
				problems.setText(rS.getString(4));

				table.addView(v);
			}
		} 
		catch (SQLException e) { e.printStackTrace(); }
	}

}
